﻿using AnQinManagermentBackendAPI.Model.DTO.ImplementManagement;
using AnQinManagermentBackendAPI.Model.View.ImplementManagement;
using AnQinManagermentBackendAPI.Service;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace AnQinManagermentBackendAPI.Controller
{
    /// <summary>
    /// 实施管理表
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    public class ImplementManagementController : ControllerBase
    {
        /**
        * 部门业务接口
        */
        private readonly ImplementManagementService _implementManagementService;

        /**
         * 构造函数注入
         */
        public ImplementManagementController(ImplementManagementService implementManagementService)
        {
            _implementManagementService = implementManagementService;
        }

        /// <summary>
        /// 获取实施管理列表
        /// </summary>
        /// <param name="implementManagementSearchDTO"></param>
        [HttpGet]
        [ProducesResponseType(typeof(ImplementManagementView), 200)]
        public async Task<IActionResult> GetImplementManagementList([FromQuery] ImplementManagementSearchDTO implementManagementSearchDTO)
        {
            var response = await _implementManagementService.GetImplementManagementList(implementManagementSearchDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 新增实施管理
        /// </summary>
        /// <param name="implementManagementAddDTO"></param>
        [HttpPost]
        public async Task<IActionResult> AddImplementManagement([FromBody] ImplementManagementAddDTO implementManagementAddDTO)
        {
            var response = await _implementManagementService.AddImplementManagement(implementManagementAddDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 更新实施管理
        /// </summary>
        /// <param name="implementManagementUpdateDTO"></param>
        [HttpPut]
        public async Task<IActionResult> PutImplementManagement([FromBody] ImplementManagementUpdateDTO implementManagementUpdateDTO)
        {
            var response = await _implementManagementService.PutImplementManagement(implementManagementUpdateDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 删除实施管理
        /// </summary>
        [HttpDelete]
        public async Task<IActionResult> DeleteImplementManagement([FromQuery] string Id)
        {
            var response = await _implementManagementService.DeleteImplementManagement(Id);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 完成实施
        /// </summary>
        [HttpPost("Finish")]
        public async Task<IActionResult> ConfirmImplementManagement([FromBody] string Id)
        {
            var response = await _implementManagementService.ConfirmImplementManagement(Id);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 仍有问题
        /// </summary>
        [HttpPost("Problem")]
        public async Task<IActionResult> ProblemImplementManagement([FromBody] string Id)
        {
            var response = await _implementManagementService.ProblemImplementManagement(Id);
            return StatusCode(response.Status, response);
        }
    }
}
